#include <bits/stdc++.h>

using namespace std;
#define int long long
unordered_map<int,string>s;
unordered_map<int,int>s1;
const int N = 1e5 + 10;
int a[N],b[N];
long long HarryPotterHashRand(const char *OriginalString) {
    char newString[0x3f3f];
    long long HashMOD = 101411234562527ll;
    memset(newString, 0, sizeof(newString));
    if (strlen(OriginalString) > 0x3f3e) return ((long long)(0xffffffff) - strlen(OriginalString));
    strcpy(newString + 1, OriginalString);
    long long seed = 111111111111111ll;
    for (int i = 1; newString[i] > 0; ++ i) {
        seed ^= (long long)(newString[i]) << 26;
        seed = ((seed << 1) + (seed << 2)) + (((long long)(newString[i]) << 34) * 10ll);
        seed *= newString[i] * 0xf;
        seed = (seed + HashMOD) % HashMOD;
    }
    return seed;
}

signed main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, c;
	cin >> n >> k >> c;
	for(int i = 1; i <= c; i++){
		cin >> a[i]; 
		a[i] += a[i - 1];
	}
	for(int i = 1; i <= n ; i++){
		string s2;
		cin >> s2;
		long long x =HarryPotterHashRand(s2.c_str());
		s[x] = s2;
		s1[x] = lower_bound(a + 1, a + c + 1, i) - a - 1;
	}
	while (k--) {
		int f;
		cin >> f;
		cout << s1[f] <<" "<< s[f] << endl;
	}
	return 0;
}
